<template>
  <view class="navbar" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
    <!-- logo文字 -->
    <view class="logo">
      <image class="logo-image" src="@/static/images/logo.png" />
      <text class="logo-text">新鲜 · 亲民 · 快捷</text>
    </view>

    <!-- 搜索条 -->
    <view class="search">
      <text class="iconfont icon-sousuo" @click="goto('/pagesGoods/goods_search/index')">搜索商品</text>
      <!-- #ifndef H5 -->
      <text class="iconfont icon-saoma"></text>
      <!-- #endif -->
    </view>
  </view>
</template>

<script setup lang="ts">
// 获取屏幕边界到安全区域的距离,不同的机型距离顶部的高度不同
const { safeAreaInsets } = uni.getSystemInfoSync()
const goto = (url:any) => {
  uni.navigateTo({url})
}
</script>

<style lang="scss">
.navbar {
  background-color: #008000;
  background-size: cover;
  display: flex;
  flex-direction: column;
  padding-top: 20px;

  // logo文字
  .logo {
    display: flex;
    align-items: center;
    height: 64rpx;
    padding-left: 30rpx;

    .logo-image {
      width: 166rpx;
      height: 39rpx;
    }

    .logo-text {
      flex: 1;
      line-height: 28rpx;
      margin: 2rpx 0 0 28rpx;
      padding-left: 20rpx;
      border-left: 1rpx solid #fff;
      font-size: 26rpx;
      color: #fff;
    }
  }

  // 搜索条
  .search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: orange;

    padding: 0 10rpx 0 26rpx;
    height: 64rpx;
    margin: 16rpx 20rpx;

    color: #fff;
    font-size: 28rpx;
    border-radius: 32rpx;
    background-color: rgba(255, 255, 255, 0.5);

    .icon-sousuo {
      width: 90%;
      height: 64rpx;
      line-height: 64rpx;
      &::before {
        margin-right: 10rpx;
      }
    }

    .icon-saoma {
      margin-right: 20rpx;
    }
  }
}
</style>